package cn.autumnorange.app.user.api;

import cn.autumnorange.app.common.dto.ResultDto;
import cn.autumnorange.app.user.api.dto.CronDto;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CronFallbackFactory implements FallbackFactory<CronService> {
  @Override
  public CronService create(Throwable throwable) {
    return new CronService() {
      @Override
      public ResponseEntity<ResultDto<CronDto>> getRolesByUserId(long cronId) {

        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
            .body(ResultDto.createMessageResult(throwable.getMessage()));
      };
    };
  }
  //  @Override
  //  public AppUserService create(Throwable throwable) {
  //    return new AppUserService() {
  //      @Override
  //      public ResponseEntity<ResultDto<UserDetailDto>> loadUserByUsername(String name) {
  //        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
  //            .body(ResultDto.createMessageResult(throwable.getMessage()));
  //      }
  //
  //      @Override
  //      public ResponseEntity<ResultDto<UserDetailDto>> loginSuccess() {
  //        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
  //            .body(ResultDto.createMessageResult(throwable.getMessage()));
  //      }
  //    };
  //  }
}
